feat: account-driven Claude — user-named accounts, opt-in per-account cost#22
Merged
Conversation
… cost Remove Claude path auto-discovery entirely. Accounts are now exactly the OAuth sign-ins (Add account), each with a user config: a display name and an optional logs-folder path. Cost + plan are opt-in per account — shown only when you point it at a logs folder (no cost API exists; cost is local JSONL × pricing), so each account attributes cost to its own dir. Type the path (tilde-expanded); blank = live-only. ClaudeReader is now account-driven (iterates tokens, per-account name/live%/cost); UsageConfig/ProviderSettings carry claudeAccountConfigs keyed by account UUID; the old ManualClaudeProfile / discovery machinery is gone (ClaudeProfileDiscovery kept for the usageprobe CLI only). Fixes: config edits (rename/cost) were re-hitting the usage endpoint → rate-limits — now a per-account usage cache (180s) plus name/path fields that commit on blur, not per keystroke. The name field pre-filled with the email and stored email-as-name — email is now a placeholder, blank = default, and a stored name==email self-heals. apply(draft) preserves live account configs. Removed the stale pre-OAuth 'Copy sign-in command' hint. From adversarial review: gate the ~/.claude.json plan fallback to the default dir (no cross-account mislabel); serve last-good usage on a transient endpoint blip so % bars don't vanish (unauthorized still surfaces); resolve the account UUID at sign-in so the config key stays stable. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (17)
📝 WalkthroughWalkthroughClaude usage moved from discovered profiles to explicitly signed-in accounts with persisted names and optional local cost-log directories. Usage is cached per account, settings edits commit on blur, and the CLI reports local Claude cost summaries separately. ChangesClaude account configuration
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant SettingsView
participant AppModel
participant UsageService
participant ClaudeReader
participant ClaudeTokenProvider
participant LocalLogs
SettingsView->>AppModel: commit account name or logs directory
AppModel->>UsageService: reconfigure account settings
UsageService->>ClaudeReader: refresh configured accounts
ClaudeReader->>ClaudeTokenProvider: request cached account usage
ClaudeTokenProvider-->>ClaudeReader: live or cached usage
ClaudeReader->>LocalLogs: read configured activity and cost logs
LocalLogs-->>ClaudeReader: tokens, plan, and cost data
ClaudeReader-->>UsageService: updated account card
Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
With our own OAuth (v0.2.0), the token already carries account identity — so scanning shell configs for
CLAUDE_CONFIG_DIRto discover Claude "profiles" is redundant, and it caused a messy account model (worktree-ish names, mis-resolution).What
Accounts are now exactly the OAuth sign-ins. Each has a user config: a name you set, and an optional logs-folder path. Cost + plan are opt-in per account — shown only when you point that account at a logs folder (there's no cost API; cost is derived from local
~/.claudeJSONL, so each account attributes cost to its own dir). Type the path (tilde-expanded); blank = live limits only.ClaudeReaderis account-driven;UsageConfig/ProviderSettingscarryclaudeAccountConfigskeyed by account UUID.ManualClaudeProfile/ auto-discovery (ClaudeProfileDiscoverykept for theusageprobeCLI only).Cost logspath + Remove; "Add account" (SSO).Fixes (some found live, some by review)
apply(draft)preserves live account edits.~/.claude.jsonplan fallback to the default dir (no cross-account plan mislabel); serve last-good usage on a transient endpoint blip so % bars don't vanish (unauthorized still surfaces); resolve account UUID at sign-in so the config key stays stable.Tests
swift testgreen (25). Verified live: add/name accounts, typed cost path shows $ + plan, rename persists across relaunch, no rate-limit on edits.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes